home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / screen.swg / 0076_GetPut Video portions.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-26  |  3.9 KB  |  132 lines

  1. (*
  2.  
  3.   Name: GETPUT
  4.   Version: 1.0
  5.   Date of release: 02/Ago/1994
  6.   Language: it can be used with Turbo Pascal 6.0  or
  7.                                 Borland Pascal 7.0
  8.  
  9.  
  10.   Donated to the public domain by:  Calabro' Davide
  11.                                     P.O.Box 65
  12.                                     21019 Somma Lombardo (VA)
  13.                                     Italy
  14.  
  15.                             E-mail: calabro@dsi.unimi.it
  16.  
  17.   Send comments,modifications or conversions in any other
  18.   language to me thanks!
  19.  
  20.  
  21.   This unit implements a useful Backup/Restore text video-portions feature.
  22.   No static buffers are used to retain the saved video memory. Be sure
  23.   to have enough heap space when call the GetVideo function or you'll get
  24.   an "Heap overflow error" at runtime!
  25.  
  26.   This is an easy example of use of the GetPut unit:
  27.  
  28.   +--- START EXAMPLE ----------------------------------------------------+
  29.   | Uses GETPUT;                                                         |
  30.   |                                                                      |
  31.   | Var A:PGetPut;  {<---- Each saved portion has its own pointer}       |
  32.   |                                                                      |
  33.   | Begin                                                                |
  34.   |   A:=GetVideo(10,10,30,5);                                           |
  35.   |              { +--|--|-|---- Start X position }                      |
  36.   |              {    +--|-|---- Start Y position }                      |
  37.   |              {       +-|---- Length on X axis }                      |
  38.   |              {         +---- Length on Y axis }                      |
  39.   |                                                                      |
  40.   |   PutVideo(A); {<---- Restore the previously saved portion       }   |
  41.   |                {      Warning: Dinamic buffer is disposed, don't }   |
  42.   |                {               call with same buffer twice!      }   |
  43.   |                                                                      |
  44.   | End.                                                                 |
  45.   +--- END EXAMPLE ------------------------------------------------------+
  46.  
  47. *)
  48.  
  49. Unit GETPUT;
  50.  
  51. INTERFACE
  52.  
  53. Type PGetPut=^TGetPut;
  54.      TGetPut=Record
  55.                Item:Byte;
  56.                Next:PGetPut;
  57.              End;
  58.  
  59. Function  GetVideo(X,Y,LX,LY:Byte):PGetPut;
  60. Procedure PutVideo(BufPunt:PGetPut);
  61.  
  62. IMPLEMENTATION
  63.  
  64. Var GenPunt1,
  65.     GenPunt2:PGetPut;
  66.     Loop1:Byte;
  67.     Loop:Word;
  68.     StartAddr:Word;
  69.  
  70. Function GetVideo;
  71. Begin
  72.   New(GenPunt1);
  73.   GetVideo:=GenPunt1;
  74.   For Loop:=1 To 4 Do
  75.     Begin
  76.       Case Loop Of
  77.         1: GenPunt1^.Item:=X;
  78.         2: GenPunt1^.Item:=Y;
  79.         3: GenPunt1^.Item:=LX;
  80.         4: GenPunt1^.Item:=LY;
  81.       End;
  82.       New(GenPunt2);
  83.       GenPunt1^.Next:=GenPunt2;
  84.       GenPunt1:=GenPunt2;
  85.     End;
  86.   StartAddr:=160*(Y-1)+2*(X-1);
  87.   For Loop1:=1 To LY Do
  88.     Begin
  89.       For Loop:=StartAddr To StartAddr+2*LX-1 Do
  90.         Begin
  91.           GenPunt1^.Item:=Mem[$B800:Loop];
  92.           New(GenPunt2);
  93.           GenPunt1^.Next:=GenPunt2;
  94.           GenPunt1:=GenPunt2;
  95.         End;
  96.       Inc(StartAddr,160);
  97.     End;
  98.   GenPunt1^.Next:=Nil;
  99. End;
  100.  
  101. Procedure PutVideo;
  102. Var X,Y,LX,LY:Byte;
  103. Begin
  104.   GenPunt1:=BufPunt;
  105.   For Loop:=1 To 4 Do
  106.     Begin
  107.       Case Loop Of
  108.         1: X:=GenPunt1^.Item;
  109.         2: Y:=GenPunt1^.Item;
  110.         3: LX:=GenPunt1^.Item;
  111.         4: LY:=GenPunt1^.Item;
  112.       End;
  113.       GenPunt2:=GenPunt1^.Next;
  114.       Dispose(GenPunt1);
  115.       GenPunt1:=GenPunt2;
  116.     End;
  117.   StartAddr:=160*(Y-1)+2*(X-1);
  118.   For Loop1:=1 To LY Do
  119.     Begin
  120.       For Loop:=StartAddr To StartAddr+2*LX-1 Do
  121.         Begin
  122.           Mem[$B800:Loop]:=GenPunt1^.Item;
  123.           GenPunt2:=GenPunt1^.Next;
  124.           Dispose(GenPunt1);
  125.           GenPunt1:=GenPunt2;
  126.         End;
  127.       Inc(StartAddr,160);
  128.     End;
  129. End;
  130.  
  131. Begin
  132. End.